import config from "@/config"
import http from "@/utils/request"

export default {
	add: {
		url: `${config.API_URL}/banner/add`,
		name: "添加banner",
		post: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.post(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	},
	update: {
		url: `${config.API_URL}/banner/update`,
		name: "修改banner",
		post: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.post(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	},
	delete: {
		url: `${config.API_URL}/banner/update`,
		name: "删除banner",
		post: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.postParam(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	},
	detail: {
		url: `${config.API_URL}/banner/detail`,
		name: "获取单条数据",
		get: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.get(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	},
	isDisable: {
		url: `${config.API_URL}/banner/disable`,
		name: "启用/禁用数据",
		post: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.postParam(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	},
	getList: {
		url: `${config.API_URL}/banner/list`,
		name: "获取列表数据",
		get: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.get(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	},

	getCompanyConfig: {
		url: `${config.API_URL}/displayCompany/list`,
		name: "获取公司数据",
		get: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.get(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	},
	updateCompanyConfig: {
		url: `${config.API_URL}/displayCompany/update`,
		name: "修改公司数据",
		post: function (data = {}) {
			return new Promise((resolve, reject) => {
				http.post(this.url, data).then((response) => {
					resolve(response)
				}).catch((error) => {
					resolve(error.data)
				})
			})
		}
	}
}